-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
compaction: remove all cache dirs at the end of each run #1587
compaction: remove all cache dirs at the end of each run #1587
Conversation
Signed-off-by: Krasi Georgiev <8903888+krasi-georgiev@users.noreply.github.com>
Signed-off-by: Krasi Georgiev <8903888+krasi-georgiev@users.noreply.github.com>
Signed-off-by: Krasi Georgiev <8903888+krasi-georgiev@users.noreply.github.com>
Signed-off-by: Krasi Georgiev <8903888+krasi-georgiev@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some questions (:
cmd/thanos/compact.go
Outdated
@@ -221,11 +221,6 @@ func runCompact( | |||
indexCacheDir = path.Join(dataDir, "index_cache") | |||
) | |||
|
|||
if err := os.RemoveAll(downsamplingDir); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we not remove it? I think we need that still. What if compactor crashes/is restarted not gracefully? Then deferred removal will fail and Thanos will use more disk then needed if not worse - might end up having corrupted blocks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not removed , it is just moved inside the .Compact() method. This makes it consitent with all the how the other components handle removing the tmp files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually I just double checked and I removed it because it is redundant as the compactor removes these before every compaction in
Lines 1044 to 1047 in 3646e13
// Clean up the compaction temporary directory at the beginning of every compaction loop. | |
if err := os.RemoveAll(c.compactDir); err != nil { | |
return errors.Wrap(err, "clean up the compaction temporary directory") | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but c.compactDir
is different then downsamplingDir
🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correction It is a duplicate of
thanos/cmd/thanos/downsample.go
Lines 134 to 136 in 95757ea
if err := os.RemoveAll(dir); err != nil { | |
return errors.Wrap(err, "clean working directory") | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes but that would be cleaned only after (!) compaction, so long time. I am 99% sure we need to keep this.
Signed-off-by: Krasi Georgiev <8903888+krasi-georgiev@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have now added tests which verify the correct behavior.
cmd/thanos/compact.go
Outdated
@@ -221,11 +221,6 @@ func runCompact( | |||
indexCacheDir = path.Join(dataDir, "index_cache") | |||
) | |||
|
|||
if err := os.RemoveAll(downsamplingDir); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not removed , it is just moved inside the .Compact() method. This makes it consitent with all the how the other components handle removing the tmp files.
Signed-off-by: Krasi Georgiev <8903888+krasi-georgiev@users.noreply.github.com>
Signed-off-by: Krasi Georgiev <8903888+krasi-georgiev@users.noreply.github.com>
ping @bwplotka |
"github.com/thanos-io/thanos/pkg/testutil" | ||
) | ||
|
||
func TestCleanupCompactCacheFolder(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not having those inside package responsible for deleting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because it will require duplicating the bootstrap function.
I thought to put the bootstrap in some reusable package, but don't think it is generic enough to be useful anywhere else.
If it happens that that func becomes useful in other tests would revisit and refactor.
cmd/thanos/compact.go
Outdated
@@ -221,11 +221,6 @@ func runCompact( | |||
indexCacheDir = path.Join(dataDir, "index_cache") | |||
) | |||
|
|||
if err := os.RemoveAll(downsamplingDir); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but c.compactDir
is different then downsamplingDir
🤔
Signed-off-by: Bartek Plotka <bwplotka@gmail.com>
a08d04b
to
3c678b2
Compare
# Conflicts: # CHANGELOG.md Signed-off-by: Bartek Plotka <bwplotka@gmail.com>
Signed-off-by: Bartek Plotka <bwplotka@gmail.com>
* remove all cache dirs at the end of each run Signed-off-by: Krasi Georgiev <8903888+krasi-georgiev@users.noreply.github.com> * changelog Signed-off-by: Krasi Georgiev <8903888+krasi-georgiev@users.noreply.github.com> * . Signed-off-by: Krasi Georgiev <8903888+krasi-georgiev@users.noreply.github.com> * changelog formating and pr num. Signed-off-by: Krasi Georgiev <8903888+krasi-georgiev@users.noreply.github.com> * added test for the compaction cleanup Signed-off-by: Krasi Georgiev <8903888+krasi-georgiev@users.noreply.github.com> * added tests Signed-off-by: Krasi Georgiev <8903888+krasi-georgiev@users.noreply.github.com> * check error Signed-off-by: Krasi Georgiev <8903888+krasi-georgiev@users.noreply.github.com> * move GatherAndCompare to tesutil Signed-off-by: Krasi Georgiev <8903888+krasi-georgiev@users.noreply.github.com> * comment Signed-off-by: Krasi Georgiev <8903888+krasi-georgiev@users.noreply.github.com> * nit Signed-off-by: Krasi Georgiev <8903888+krasi-georgiev@users.noreply.github.com> * Added back deletion of the downsampling dir. Signed-off-by: Bartek Plotka <bwplotka@gmail.com> * Fix after pull master. Signed-off-by: Bartek Plotka <bwplotka@gmail.com> Signed-off-by: Giedrius Statkevičius <giedriuswork@gmail.com>
Signed-off-by: Krasi Georgiev 8903888+krasi-georgiev@users.noreply.github.com
fixes: #1499
TODO